pub fn odd_fibnacci_sum(threshold: u32) -> u32 {
    fibnacci()
        .take(threshold as usize)
        .collect::<Vec<u32>>()
        .iter()
        .filter(|n| *n % 2 != 0 && **n < threshold)
        .sum::<u32>()
}

pub fn fibnacci() -> impl Iterator<Item = u32> {
    let mut state = (0, 1);
    std::iter::from_fn(move || {
        state = (state.1, state.0 + state.1);
        Some(state.0)
    })
}

#[test]
fn test_fibnacci() {
    let sum = odd_fibnacci_sum(20);
    assert_eq!(sum, 23)
}
